package com.c.ctgproject.adapter.guang

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.*
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.R
import com.c.ctgproject.base.BaseEmptyRecyclerViewAdapterV2
import com.c.ctgproject.entity.guang.*
import com.c.ctgproject.ui.collect.*
import com.c.ctgproject.utils.MyConstants
import com.c.ctgproject.utils.getGson
import com.c.ctgproject.utils.handlerNull
import com.c.ctgproject.utils.noDataHandler
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.textColorResource

class MaterialOutOrderAdapter(private val context: Context, private val mList: List<MaterialOutOrderEntity.DataBean.ListBean>) : BaseEmptyRecyclerViewAdapterV2(context, mList) {
    override fun createViewHolder(parent: ViewGroup): RecyclerView.ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_material_out_order_list, parent, false)
        return MyViewHolder(view)
    }

    override fun handlerData(holder: RecyclerView.ViewHolder, position: Int) {
        if (holder is MyViewHolder) {
            val data = mList[position]
            holder.mUserNameTV.text = data.createPersonName.noDataHandler()
            holder.mTimeTV.text = data.createTime.noDataHandler()
            holder.mNo.text = data.bizNo.noDataHandler()




//            val dismantleMethod = when (data.outType) {
//                1 -> "销售出库"
//                2 -> "借用出库"
//                3 -> "其他出库"
//                else -> "暂无数据"
//            }
//            holder.dismantleMethod.text = dismantleMethod
//
//
            holder.mParentLL.setOnClickListener {
                //查看详情

                context.startActivity<MaterialOutDetailActivity>(MyConstants.ORDER_ID to data.outOrderId,
                    MyConstants.DATA to data
                    )
//                context.startActivity<PartDetailActivity>(MyConstants.ORDER_ID to data.orderId)
//                context.startActivity<BatteryDetailActivity>(MyConstants.ORDER_ID to data.orderId)
            }

        }
    }


    inner class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val mStatueTV: TextView = view.findViewById(R.id.mStatueTV)
        val mUserNameTV: TextView = view.findViewById(R.id.mUserNameTV)
        val mNo: TextView = view.findViewById(R.id.mNo)
        val mTimeTV: TextView = view.findViewById(R.id.mTimeTV)

        //        val dismantleMethod: TextView = view.findViewById(R.id.dismantleMethod)
//        val mBTN: Button = view.findViewById(R.id.mBTN)
        val mParentLL: LinearLayoutCompat = view.findViewById(R.id.mParentLL)
        val mClientTV: TextView = view.findViewById(R.id.mClientTV)

    }


}